import {createRouter, createWebHistory} from "vue-router";
//createWebHistory路由模式路径不带#号,生产环境下不能直接访问项目，需要nginx转发
//createWebHashHistory路由模式路径带#号

const router = createRouter({
    history: createWebHistory(),//history: createWebHashHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: "/",
            name: "Layout", //框架
            component: () => import("../layout/Layout.vue"),
            redirect: "/index",
            children: [
                {
                    path: "/userManage",
                    name: "UserManage",
                    component: () => import('@/views/userManage/userManage.vue')  //用户管理
                },
                {
                    path: '/fileManage',
                    name: "FileManage",
                    component: () => import('@/views/fileManage/fileManage.vue')  //文件管理
                },
                {
                    path: '/permissionManage',
                    name: "PermissionManage",
                    component: () => import('@/views/permissionManage/permissionManage.vue')  //权限管理
                },
                {
                    path: '/industryClassificationManage',
                    name: "IndustryClassificationManage",
                    component: () => import('@/views/classificationManage/industryClassificationManage.vue')  //行业分类
                },
                {
                    path: '/domainClassificationManage',
                    name: "DomainClassificationManage",
                    component: () => import('@/views/classificationManage/domainClassificationManage.vue')  //领域分类
                },
                {
                    path: '/index',
                    name: "Index",
                    component: () => import('@/views/index/index.vue')  //首页
                },
                {
                    path: '/myFile',
                    name: "MyFile",
                    component: () => import('@/views/myFile/myFile.vue')  //我的文件
                },
                {
                    path: '/specificationLibrary',
                    name: "SpecificationLibrary",
                    component: () => import('@/views/specificationLibrary/specificationLibrary.vue')  //规范库
                },
                {
                    path: '/inviteTendersFileAnalysis',
                    name: "InviteTendersFileAnalysis",
                    component: () => import('@/views/inviteTendersFileAnalysis/inviteTendersFileAnalysis.vue')  //招标文件分析
                },
                {
                    path: '/fileMatchingAnalysisOfInviteTenders',
                    name: "FileMatchingAnalysisOfInviteTenders",
                    component: () => import('@/views/fileMatchingAnalysisOfInviteTenders/fileMatchingAnalysisOfInviteTenders.vue')  //招投标文件匹配分析
                },
                {
                    path: '/automaticBidEvaluation',
                    name: "AutomaticBidEvaluation",
                    component: () => import('@/views/automaticBidEvaluation/automaticBidEvaluation.vue')  //自动评标
                },
                {
                    path: '/inviteTendersFileSpecification',
                    name: "InviteTendersFileSpecification",
                    component: () => import('@/views/inviteTendersFileSpecification/inviteTendersFileSpecification.vue')  //招标文件规范
                },
                {
                    path: '/test',
                    name: "Test",
                    component: () => import('@/views/test.vue')  //测试页面
                },
            ],
        },
        // {
        //   path: "/login",
        //   name: "Login",
        //   component: () => import("../component/LoginView.vue"),
        // },
        // {
        //   path: "/register",
        //   name: "Register",
        //   component: () => import("../component/RegisterView.vue"),
        // },
        // {
        //   path: "/header",
        //   name: "Header",
        //   component: () => import("../component/HeaderView.vue"),
        // },
        // {
        //   path: "/aside",
        //   name: "Aside",
        //   component: () => import("../component/AsideView.vue"),
        // },
    ],
});

//登录拦截
// 配置路由守卫  三个可选参数，to去往的目标，from来源的目标对象，next接下来的操作
// router.beforeEach((to, from, next) => {
//     console.log(to.path)
//     // 如果访问的是登录和注册页面，直接放行
//     if (to.path === '/login' || to.path === '/register') {
//         return next()
//     }
//     // 如果用户未登录，并且访问的不是登录页面
//     const Session = JSON.parse(sessionStorage.getItem('userLoginData'))
//     console.log("输出的Session：")
//     console.log(Session)
//     if (!Session) {
//         return next('/login')
//     }
//     // 如果已经登陆，则直接放行
//     next();
// })

export default router;
